<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    /**
     * __construct
     * @param Zend_Application $application
     */
    public function __construct($application)
    {
        parent::__construct($application);

        /* @var $fc Zend_Controller_Front */
        $this->bootstrap('frontController');
        $fc = $this->getResource('frontController');

        /* Registre */
        Zend_Registry::setClassName('Tv_Arte_Reg');
        
        /* App */
        Tv_Arte_Reg::setApp($this->getApplication());
        
        /* Session */
        Tv_Arte_Reg::setSession(new Zend_Session_Namespace('Tv_Arte_session'));
        


        /* @var $fc Zend_Controller_Front */
        /*$this->bootstrap('frontController');
        $fc = $this->getResource('frontController');*/
        Zend_Controller_Action_HelperBroker::addPath(
            realpath(APPLICATION_PATH . '/library/Tv/Arte/Helpers/Action'),
            'Tv_Arte_Helpers_Action'
        );

        /* @var $view Zend_View */
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT'); // pour que les forms soient rendus en xhtml
        $view->addHelperPath(realpath(APPLICATION_PATH . '/library/Tv/Arte/Helpers/View'), 'Tv_Arte_Helpers_View');

        /* @var $db Zend_Db_Adapter_Abstract */
        $this->bootstrap('Db');
        $db = $this->getResource('Db');
        $db->query('SET NAMES UTF8');
        Zend_Db_Table_Abstract::setDefaultAdapter($db);
        Tv_Arte_Reg::setDb($db);

        /* Gestionnaire d'erreurs global */
        $fc->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(Array(
            'module' => 'default',
            'controller' => 'error',
            'action' => 'error'
        )));

        /* Langue de l'admin par defaut */
        /*$locale = new Zend_Locale();
        $localeString = $locale->findLocale();
        $translate = new Zend_Translate('ini', APPLICATION_PATH . '/configs/admin_fr_FR.ini', 'fr_FR');
        $translate->getAdapter()->addTranslation(APPLICATION_PATH . '/configs/admin_fr_FR.ini', 'fr');
        $translate->getAdapter()->setLocale((!$translate->getAdapter()->isAvailable($localeString)) ? 'fr_FR' : $localeString);
        BSCore_Utils_Registry::setTranslate($translate->getAdapter());
        // Activation de l'aide de vue translate
        BSCore_Utils_Registry::set('Zend_Translate', $translate); */





        /* ACL */
        /*$acl = new Zend_Acl();
        $aclPlugin = new BSCore_Helpers_FrontController_Acl($acl);
        $bscore = $application->getOption('bscore');
        $aclArray = $bscore['acl'];
        $aclPlugin->setPermissions($aclArray);
        if (BSCore_Auth_Adapter::isConnected()) {
            $identity = BSCore_Auth_Adapter::getAuthResult()->getIdentity();
            $aclPlugin->setRoleName($identity['role']);
        } else {
            $aclPlugin->setRoleName($aclArray['defaultRole']);
        }
        $fc->registerPlugin($aclPlugin);

        $fc->registerPlugin(new BSCore_Helpers_FrontController_History(BSCore_Utils_Registry::getSession())); */
    }
}